home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Blitz2 / BlitzFaq / FaqLists / Circularshape.txt < prev    next >
Encoding:
Text File  |  1996-08-31  |  1.8 KB  |  84 lines

  1. WBStartup
  2.  
  3. #_BitMap=$8000002E
  4. #_LikeWorkbench=$80000047
  5.  
  6. ; Define our bitmaps and open a new screen same as WB to show
  7. ; output on.
  8. ; Bitmap 2 = new shape
  9. ; Bitmap 3 = new shape mask
  10.  
  11. WbToScreen 0
  12. ScreensBitMap 0,0
  13. BitMap 2,32,32,WBDepth
  14. CopyBitMap 2,3
  15. BitMap 1,WBWidth,WBHeight,WBDepth
  16. ScreenTags 1,"Copy Circle",#_BitMap,Addr BitMap(1),#_LikeWorkbench,True
  17.  
  18. ; Work out the max number of colours available
  19.  
  20. maxcol=1 LSL WBDepth
  21.  
  22. ;maxcol=1
  23. ;For n=1 To WBDepth
  24. ;  maxcol=maxcol*2
  25. ;Next
  26.  
  27. ; Draw the circular mask, 32 pixel diameter and then cut it
  28. ; out to the mask bitmap
  29.  
  30. Use BitMap 1
  31. Use Screen 1
  32. Circlef 50,50,16,16,maxcol-1
  33. Use BitMap 3
  34. Scroll 50-16,50-16,32,32,0,0,1
  35. Use BitMap 1
  36. Cls 0
  37.  
  38. ; Ok, now cut out a 32x32 pixel block from the WB to use as our
  39. ; shape.
  40.  
  41. Use BitMap 2
  42. Scroll 0,0,32,32,0,0,0
  43.  
  44. ; Get the addresses of the bitmap objects to find out the actual
  45. ; bitplane addresses of the shape and mask.
  46.  
  47. shape_object.l=Addr BitMap (2)
  48. mask_object.l=Addr BitMap (3)
  49.  
  50. ; This actually works through the block cut from the WB, word by word,
  51. ; and logically AND's it with the circular mask. This then produces
  52. ; the new cirular shape.
  53.  
  54. For y=0 To WBDepth-1
  55.   shape_bitmap.l=Peek.l (shape_object+8+(y*4))
  56.   mask_bitmap.l=Peek.l  (mask_object+8+(y*4))
  57.   For n=0 To 64*2-1
  58.     cshape.w=Peek.w (shape_bitmap+n)
  59.     mask.w=Peek.w (mask_bitmap+n)
  60.     Poke.w  shape_bitmap+n,cshape.w AND mask.w
  61.   Next n
  62. Next y
  63.  
  64. ; Now produce a standard Blitz shape from the new circular one.
  65.  
  66. Use BitMap 2
  67. GetaShape 1,0,0,32,32
  68.  
  69. ; Finally, put some random boxes on the screen and blit 10 copies
  70. ; of out new circular shape.
  71.  
  72. Use BitMap 1
  73. For n=1 To 20
  74.   Boxf Rnd(WBWidth-32),Rnd(WBHeight-32),Rnd(WBWidth-32),Rnd(WBHeight-32),Rnd(maxcol-1)
  75. Next n
  76. BlitMode CookieMode
  77. For n=1 To 10
  78.   Blit  1,Rnd(WBWidth-32),Rnd(WBHeight-32)
  79. Next n
  80.  
  81. ClickMouse
  82.  
  83. End
  84.